{% extends 'front/user_base.html' %}
{% block css %}
    <link rel="stylesheet"
          href="{{ url_for('static', filename='css/pure-min.css') }}">
    <link rel="stylesheet"
          href="{{ url_for('static', filename='css/create.css') }}">
    <style>
    input#title{
        height: 3rem;
    }
   .pure-form  select {
        height: 3rem;
    }
    </style>
{% endblock %}
{% block content %}

<div class="content">
    <div class="header">
        <h2>编辑分享</h2>
    </div>
    <div class="pure-g">
        {% for category, message in get_flashed_messages(with_categories=true) %}
            <div class="alert alert-{{ category }} alert-dismissable pure-u-1 pure-u-md-21-24">
                {{ message }}
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            </div>
        {% endfor %}
        <form class="pure-form  pure-form-aligned pure-u-1 pure-u-md-21-24" action="{{ url_for('main.update_post') }}" method="post" onsubmit="return checkPost()">
            <fieldset>
                {{ form.csrf_token }}
                {{ form.post_id(class='pure-u-2-3', id="post_id") }}
                <div class="pure-control-group ">
                    {{ form.title(class='pure-u-4-5', id="title",placeholder="输入名称", required='') }}
                </div>
                <div class="pure-control-group">
{#                    <label for="desc" class="pure-u-1-3">俱乐部</label>#}
                    {{ form.club_id(class='pure-u-4-5', id="club_id",placeholder="选择俱乐部", required='') }}
                </div>
                <div class="pure-control-group">
{#                    <label for="password" class="pure-u-1-3">内容</label>#}
                    {{ form.content(class='pure-u-5-5',rows='7', id="content",placeholder="输入内容，字数不能少于6个字符", required='') }}
                </div>
                <div class="pure-controls-group" style="text-align: right">
                    <button type="submit" class="button-success pure-button button-large pure-u-3-3">
                        保存
                    </button>
                </div>
            </fieldset>
        </form>
    </div>
</div>
{% endblock %}
{% block scripts %}
    <script src="{{ url_for('static', filename='layer-v3.5.1/layer.js') }}"></script>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='plugins/simditor-2.3.28/site/assets/styles/simditor.css') }}" />
    <script type="text/javascript" src="{{ url_for('static', filename='plugins/simditor-2.3.28/site/assets/scripts/module.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='plugins/simditor-2.3.28/site/assets/scripts/hotkeys.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='plugins/simditor-2.3.28/site/assets/scripts/uploader.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='plugins/simditor-2.3.28/site/assets/scripts/simditor.js') }}"></script>
<script>
    var editor = new Simditor({
      textarea: $('#content')
      //optional options
    });
    function checkPost(){
        let title = jQuery("#title").val()
        let testPlain = simplemde.value()
        console.log(testPlain)
        content = simplemde.markdown(testPlain);
        $("textarea#content").val(testMarkdown);
        if(title.length < 5){
            layer.msg("名称不能小于5个字符")
            return false
        }
        if(content.length < 6 ){
            layer.msg("内容长度不能少于6个字符")
            return false
        }
        return true
    }
    </script>
{% endblock %}